home *** CD-ROM | disk | FTP | other *** search
- /*
- ==============================================================================
-
- Martian War Machine
-
- ==============================================================================
- */
-
- #include "g_local.h"
- #include "m_war_machine.h"
-
-
- static int sound_pain;
- static int sound_die;
- static int sound_idle;
- static int sound_punch;
- static int sound_sight;
- static int sound_search;
-
- void warmach_sight (edict_t *self, edict_t *other)
- {
- gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
- }
-
- void warmach_search (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0);
- }
-
-
- void warmach_fidget (edict_t *self);
- mframe_t warmach_frames_stand [] =
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
-
- };
- mmove_t warmach_move_stand = {FRAME_stand01, FRAME_stand08, warmach_frames_stand, NULL};
-
- void war_stomp_right (edict_t *self)
- {
- int i;
- edict_t *e;
- vec3_t forward, right;
- vec3_t start;
-
- for (i=1, e=g_edicts+i; i < globals.num_edicts; i++,e++)
- {
- if (!e->inuse)
- continue;
- if (!e->client)
- continue;
- if (!e->groundentity)
- continue;
-
- e->groundentity = NULL;
- e->velocity[0] += crandom()* 50;
- e->velocity[1] += crandom()* 50;
- e->velocity[2] += crandom()* 100;
- }
-
- AngleVectors (self->s.angles, forward, right, NULL);
- VectorCopy (self->s.origin, start);
-
- //start[2] = start[2] - 16;
-
- right[0] = right[0] * 105;
- right[1] = right[1] * 105;
- forward[0] = forward[0] * 10;
- forward[1] = forward[1] * 10;
-
- VectorAdd(start, forward, start);
- VectorAdd(start, right, start);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION2);
- gi.WritePosition (start);
- gi.multicast (start, MULTICAST_PVS);
-
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
- }
-
- void war_stomp_left (edict_t *self)
- {
- int i;
- edict_t *e;
- vec3_t forward, right;
- vec3_t start;
-
- for (i=1, e=g_edicts+i; i < globals.num_edicts; i++,e++)
- {
- if (!e->inuse)
- continue;
- if (!e->client)
- continue;
- if (!e->groundentity)
- continue;
-
- e->groundentity = NULL;
- e->velocity[0] += crandom()* 50;
- e->velocity[1] += crandom()* 50;
- e->velocity[2] += crandom()* 100;
- }
-
- AngleVectors (self->s.angles, forward, right, NULL);
- VectorCopy (self->s.origin, start);
-
- //start[2] = start[2] - 16;
-
- right[0] = right[0] * -100;
- right[1] = right[1] * -100;
-
- forward[0] = forward[0] * 15;
- forward[1] = forward[1] * 15;
-
- VectorAdd(start, forward, start);
-
- VectorAdd(start, right, start);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION2);
- gi.WritePosition (start);
- gi.multicast (start, MULTICAST_PVS);
-
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
-
- }
- void war_stomp_middle (edict_t *self)
- {
- int i;
- edict_t *e;
- vec3_t forward, right;
- vec3_t start;
-
- for (i=1, e=g_edicts+i; i < globals.num_edicts; i++,e++)
- {
- if (!e->inuse)
- continue;
- if (!e->client)
- continue;
- if (!e->groundentity)
- continue;
-
- e->groundentity = NULL;
- e->velocity[0] += crandom()* 50;
- e->velocity[1] += crandom()* 50;
- e->velocity[2] += crandom()* 100;
- }
-
- AngleVectors (self->s.angles, forward, right, NULL);
- VectorCopy (self->s.origin, start);
-
- //start[2] = start[2] - 16;
-
- forward[0] = forward[0] * 185;
- forward[1] = forward[1] * 185;
-
- VectorAdd(start, forward, start);
-
- VectorAdd(start, right, start);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION2);
- gi.WritePosition (start);
- gi.multicast (start, MULTICAST_PVS);
-
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
- }
-
- void warmach_stand (edict_t *self)
- {
- self->monsterinfo.currentmove = &warmach_move_stand;
- }
-
-
-
-
- mframe_t warmach_frames_run1 [] =
- {
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, war_stomp_middle,
- ai_run, 25, NULL,
- ai_run, 30, war_stomp_right,
- ai_run, 25, NULL,
- ai_run, 20, NULL,
- ai_run, 15, war_stomp_left
- };
- mmove_t warmach_move_run1 = {FRAME_walk01, FRAME_walk12, warmach_frames_run1, NULL};
-
- void warmach_run (edict_t *self)
- {
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- self->monsterinfo.currentmove = &warmach_move_stand;
- else
- self->monsterinfo.currentmove = &warmach_move_run1;
-
- gi.sound (self, CHAN_WEAPON, sound_idle, 1, ATTN_NORM, 0);
- }
-
- void warmach_laser_right (edict_t *self)
- {
- vec3_t forward, right;
- vec3_t start;
- vec3_t end;
- vec3_t dir;
- vec3_t from;
- int damage = 20;
- int flash_number = MZ2_MAKRON_BFG;
- trace_t tr;
-
- AngleVectors (self->s.angles, forward, right, NULL);
- G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
- VectorCopy (self->s.origin, start);
- VectorCopy (self->enemy->s.origin, end);
- end[2] += self->enemy->viewheight;
- VectorSubtract (end, start, dir);
-
- right[0] = right[0] * 95;
- right[1] = right[1] * 95;
- start[2] = start[2] + 270;
-
- VectorAdd(start, right, start);
-
- end[2] = end[2] - 32;
-
- VectorCopy (start, from);
- tr = gi.trace (from, NULL, NULL, end, self, MASK_SHOT);
- VectorCopy (tr.endpos, from);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_SHOTGUN);
- gi.WritePosition (start);
- gi.WritePosition (end);
- gi.multicast (start, MULTICAST_PHS);
- gi.sound (self, CHAN_VOICE, sound_punch, 1, ATTN_NORM, 0);
-
- if ((tr.ent != self) && (tr.ent->takedamage))
- T_Damage (tr.ent, self, self, dir, tr.endpos, tr.plane.normal, damage, 0, 0, MOD_HYPERBLASTER);
- else if (!((tr.surface) && (tr.surface->flags & SURF_SKY)))
- {
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_SCREEN_SPARKS);
- gi.WritePosition (tr.endpos);
- gi.WriteDir (tr.plane.normal);
- gi.multicast (self->s.origin, MULTICAST_PVS);
- }
- }
-
- void warmach_laser_left (edict_t *self)
- {
- vec3_t forward, right;
- vec3_t start;
- vec3_t end;
- vec3_t dir;
- vec3_t from;
- int damage = 20;
- int flash_number = MZ2_MAKRON_BFG;
- trace_t tr;
-
- AngleVectors (self->s.angles, forward, right, NULL);
- G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
- VectorCopy (self->s.origin, start);
- VectorCopy (self->enemy->s.origin, end);
- end[2] += self->enemy->viewheight;
- VectorSubtract (end, start, dir);
-
- right[0] = right[0] * -100;
- right[1] = right[1] * -100;
- start[2] = start[2] + 280;
-
- VectorAdd(start, right, start);
-
- end[2] = end[2] - 32;
-
- VectorCopy (start, from);
- tr = gi.trace (from, NULL, NULL, end, self, MASK_SHOT);
- VectorCopy (tr.endpos, from);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_SHOTGUN);
- gi.WritePosition (start);
- gi.WritePosition (end);
- gi.multicast (start, MULTICAST_PHS);
- gi.sound (self, CHAN_VOICE, sound_punch, 1, ATTN_NORM, 0);
-
- if ((tr.ent != self) && (tr.ent->takedamage))
- T_Damage (tr.ent, self, self, dir, tr.endpos, tr.plane.normal, damage, 0, 0, MOD_HYPERBLASTER);
- else if (!((tr.surface) && (tr.surface->flags & SURF_SKY)))
- {
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_SCREEN_SPARKS);
- gi.WritePosition (tr.endpos);
- gi.WriteDir (tr.plane.normal);
- gi.multicast (self->s.origin, MULTICAST_PVS);
- }
- }
-
- mframe_t warmach_frames_attack_laser [] =
- {
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, warmach_laser_right,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, warmach_laser_left,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL
- };
-
- mmove_t warmach_move_attack_laser = {FRAME_atta01, FRAME_atta12, warmach_frames_attack_laser, warmach_run};
-
-
- void warmach_melee (edict_t *self)
- {
- self->monsterinfo.currentmove = &warmach_move_attack_laser;
- }
-
- void warmach_pain (edict_t *self, edict_t *other, float kick, int damage)
- {
- gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
- }
-
- void warmach_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
- {
- int n, spd;
- vec3_t start, org;
-
- // tower of fire code here (will add body parts flying next)
- VectorCopy (self->s.origin, start);
- for (n = 1; n < 5; n++)
- {
- start[2] = start[2] + 64;
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION1);
- gi.WritePosition (start);
- gi.multicast (start, MULTICAST_PVS);
- }
- /*
- for (n = 0; n < 2; n++)
- {
- spd = 5;
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/gibs/war_tent/tris.md2", spd, org);
- }
- */
- for (n = 0; n < 3; n++)
- {
- spd = 5;
- org[0] = self->s.origin[0] + crandom() * 5.0;
- org[1] = self->s.origin[1] + crandom() * 5.0;
- org[2] = self->s.origin[2] + crandom() * 5.0;
- ThrowDebris (self, "models/objects/gibs/war_leg/tris.md2", spd, org);
- }
-
- ThrowHead (self, "models/objects/gibs/war_body/tris.md2", damage, GIB_METALLIC, 0);
-
- self->deadflag = DEAD_DEAD;
- self->takedamage = DAMAGE_NO;
- VectorSet (self->mins, -32, -32, 0);
- VectorSet (self->maxs, 32, 32, 8);
- self->movetype = MOVETYPE_TOSS;
- self->nextthink = 0;
- self->think = NULL;
- }
-
- /*QUAKED monster_warmach (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
- */
- void SP_monster_warmach (edict_t *self)
- {
- if (deathmatch->value)
- {
- G_FreeEdict (self);
- return;
- }
-
- // pre-caches
- sound_pain = gi.soundindex ("martian/robotmove.wav");
-
-
- sound_punch = gi.soundindex ("martian/shoot1.wav");
- sound_search = gi.soundindex ("world/engine3.wav");
- sound_sight = gi.soundindex ("world/engine3.wav");
-
- sound_idle = gi.soundindex ("world/engine3.wav");
- sound_die = gi.soundindex ("martian/step.wav");
-
- self->s.modelindex = gi.modelindex("models/monsters/martian_war/tris.md2");
- VectorSet (self->mins, -48, -48, 0);
- VectorSet (self->maxs, 48, 48, 256);
- self->movetype = MOVETYPE_STEP;
- self->solid = SOLID_BBOX;
- self->s.skinnum = 0;
-
- self->max_health = 600; // for testing
- self->health = self->max_health;
- self->gib_health = 0;
- self->mass = 2450;
-
- self->classname = "monster_ambass";
-
- self->pain = warmach_pain;
- self->die = warmach_die;
-
- self->monsterinfo.stand = warmach_stand;
- self->monsterinfo.walk = warmach_run;
- self->monsterinfo.run = warmach_run;
- self->monsterinfo.dodge = NULL;
- self->monsterinfo.attack = warmach_melee;
- self->monsterinfo.melee = warmach_melee;
- self->monsterinfo.sight = warmach_sight;
- self->monsterinfo.search = warmach_search;
-
- self->monsterinfo.currentmove = &warmach_move_stand;
- self->monsterinfo.scale = MODEL_SCALE;
-
- gi.linkentity (self);
-
- walkmonster_start (self);
- }
-
-